import java.util.HashMap;
import java.util.Map;

/**
 * Created by losor on 2017/3/8.
 */
public class _447_NumberOfBoomerangs {



    public int numberOfBoomerangs(int[][] points) {
        int count = 0;
        int[][] a = new int[points.length][points.length];
            Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < points.length; i++) {
            for (int j = 0; j < points.length; j++) {
                int l = points[i][0] - points[j][0];
                int w = points[i][1] - points[j][1];
                map.put(l*l + w*w,map.getOrDefault(l*l + w*w,0)+1);
            }
            for (int c: map.values()
            ){
                count += (1+(c-1))* (c-1) / 2;
            }
            map.clear();
        }
        return count*2;
    }
}
